package net.hn.hnms.biz.common.activiti.builder;


import net.hn.hnms.biz.common.activiti.params.ProcessParam;
import net.hn.hnms.biz.common.activiti.result.DeployResult;
import net.hn.hnms.biz.common.activiti.service.ProcessApiService;

/**
 * Created on 2022/8/5.
 *
 * @author ly
 * @desc: 使用自定义流程生成数据创建流程
 */
public class DataProcessCreator {
    private ProcessApiService processApiService;

    //自定义流程生成数据
    private ProcessParam request;

    private DataProcessCreator() {}

    public DataProcessCreator(ProcessApiService processApiService) {
        this.processApiService = processApiService;
    }

    /**
     * 设置自定义流程生成数据
     * @param request 自定义流程生成数据
     * @return DataProcessCreator 流程创建器
     */
    public DataProcessCreator workFlowRequest(ProcessParam request) {
        this.request = request;
        return this;
    }

    /**
     * 部署流程
     * @return 生成流程并部署
     */
    public DeployResult deploy() {
        return processApiService.createWorkFlow(request);
    }
}
